﻿@using MobiShop.Models
@model MobiShop.Models.FindProductData

@{
    ViewBag.Title = "Quản lý sản phẩm";
    Layout = "~/Views/Shared/_AdminStart.cshtml";
    if(ViewBag.SoKetQua == null){
        ViewBag.SoKetQua = 0;
    }
}
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<div class="titleForm">
    <h3>Danh sách sản phẩm</h3>
</div>
<div class="linkCommand">
    @Html.ActionLink("Thêm mới", "productCreate")
</div>

@using (Html.BeginForm("productList", "Admin", new { id = 1 }, FormMethod.Get))
    {
    @Html.ValidationSummary(true)

    <div class="boxtCreateCenter" style="width:500px;" >
        <fieldset >
            <legend>Tìm kiếm sản phẩm</legend>
            <table>
                <tr>
                    <td style="width:80px;">
                        @Html.LabelFor(model => model.name)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.name, new { style = "width:200px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.manufactureId)
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.manufactureId, (SelectList)ViewBag.listManufacture, "Chọn tất cả", new { @style = "width:125px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.categoryId)
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.categoryId, (SelectList)ViewBag.listCategory, "Chọn tất cả",  new { @style = "width:125px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.regionId)
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.regionId, (SelectList)ViewBag.listRegion, "Chọn tất cả", new { @style = "width:125px;" })
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.priceFrom)
                    </td>
                    <td>
                        @Html.TextBoxFor(model => model.priceFrom, new { style = "width:70px;" })

                        @Html.LabelFor(model => model.priceTo)
                        @Html.TextBoxFor(model => model.priceTo, new { style = "width:70px;" })

                        @Html.ValidationMessageFor(model => model.priceFrom)
                        @Html.ValidationMessageFor(model => model.priceTo)
                    </td>
                </tr>
                <tr>
                    <td>
                        @Html.LabelFor(model => model.visible)
                    </td>
                    <td>
                        @Html.DropDownListFor(model => model.visible, (List<SelectListItem>)ViewBag.VisibleListItem)
                    </td>
                </tr>
                <tr>
                    <td>
                    
                    </td>
                    <td>
                        <input type="submit" value="Tìm kiếm" id="btnSeach" />
                    </td>
                </tr>
            </table>
        </fieldset>
    </div>
    }
Tìm được tất cả @ViewBag.SoKetQua kết quả <br />
<a href="@ViewBag.CurrentLink" style="font-size:16px;">Refesh</a>

<div>
        <table cellspacing="1" cellpadding="5">
            <tr class = "boxListHeader">
                <th style = "width:60px">Thao tác</th>
                <th style = "width:200px">
                    TÊN
                </th>
                <th style = "width:100px">
                    Giá
                </th>
                <th style = "width:460px">
                    Mô tả
                </th>
                <th style = "width:100px">
                    Hình ảnh
                </th>
                <th style = "width:20px">
                    Ngày tạo
                </th>
                <th style = "width:20px">
                    Số lượng
                </th>
                <th style = "width:20px">
                    Trạng thái
                </th>
            </tr>
            @{
                int i = 0;
                string s = "";
            }

@if (ViewBag.ResultList != null)
{
        foreach (MobiShop.Models.Product item in ViewBag.ResultList)
        {
            i++;

            if (i % 2 == 0)
            {
                s = "boxList1";
            }
            else
            {
                s = "boxList2";
            }
            <tr class ="@s">
                <td>
                    @Html.ActionLink("Edit", "productEdit", new { id = item.id }) |
                    @Html.ActionLink("Delete", "productDelete", new { id = item.id })
                </td>
                <td>
                    @item.name
                </td>
                <td>
                    @String.Format("{0:F}", item.price)
                </td>
                <td>
            
                    @item.description
                </td>
                <td>
                    <img src="@Url.Content("~/Content/images/" + @item.image)" width="111" alt="" height="109" />
                </td>
                <td>
                    @String.Format("{0:MM/dd/yyyy}", item.createDate)
                </td>
                <td>
                    @item.totalQuantity
                </td>
                <td>@if (item.visible != null && item.visible.Value)
                    {
                        <span>Đã kích hoạt</span>
                    }
                    else
                    {
                        <span>Chưa kích hoạt</span>
                    }
                </td>
            </tr>
        }
}
        </table>
</div>


@if (ViewBag._tongSoTrang != null && (int)ViewBag._tongSoTrang >= 1)
{
    @Html.Partial("_BoPhanTrang")
}